﻿Imports System.Windows.Forms
Imports System.Drawing

<Serializable()> Public Class ParallelogramTool
    Inherits BaseTool


    Dim dp3 As New Point
    Dim dp4 As New Point

    Dim dp3_old As New Point
    Dim dp4_old As New Point

    Dim pt As New Point
    Dim Xlength As Integer
    Dim Ylength As Integer

    Public Overrides Sub mouseDblClick(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub

    Public Overrides Sub mouseDown(ByVal sender As Object, ByVal e As AxMapWinGIS._DMapEvents_MouseDownEvent)
        If e.button = 1 Then



            If Me.OperShapeProperty Is Nothing Then '第一次绘制



                Me.OperShapeProperty = ShapeFactory.getNewLineShape()


                Me.OperShapeProperty.P1Property = Me.DownPointProperty
                Me.OperShapeProperty.plist.Add(Me.DownPointProperty)


                dp3_old = Me.DownPointProperty


            Else

                '绘制第二个点的情况
                If Me.OperShapeProperty.plist.Count = 1 Then

                    Me.OperShapeProperty.plist.Add(Me.DownPointProperty)

                    ControlPaint.DrawReversibleLine(getScreen(Me.OperShapeProperty.plist.Item(0)), getScreen(Me.DownPointProperty), lColor)

                    dp4_old = Me.DownPointProperty

                Else

                    '绘制第三个点以及第四个点的情况
                    If Me.OperShapeProperty.plist.Count = 2 Then



                        Me.OperShapeProperty.plist.Add(Me.DownPointProperty)

                        Me.OperShapeProperty.plist.Add(dp4)



                        InvokeEndDrawing()
                        Me.OperShapeProperty = Nothing

                    End If


                End If








            End If

        End If

    End Sub

    Public Overrides Sub mouseDrag(ByVal sender As Object, ByVal e As AxMapWinGIS._DMapEvents_MouseMoveEvent)

    End Sub

    Public Overrides Sub mouseMove(ByVal sender As Object, ByVal e As AxMapWinGIS._DMapEvents_MouseMoveEvent)
        If Me.OperShapeProperty.plist.Count = 1 Then

            ControlPaint.DrawReversibleLine(getScreen(Me.OperShapeProperty.plist.Item(0)), getScreen(Me.OldmovepointProperty), lColor)

            ControlPaint.DrawReversibleLine(getScreen(Me.OperShapeProperty.plist.Item(0)), getScreen(Me.NewmovepointProperty), lColor)

        End If


        If Me.OperShapeProperty.plist.Count = 2 Then
            pt.X = e.x
            pt.Y = e.y


            dp3.X = e.x
            dp3.Y = e.y


            Xlength = Me.OperShapeProperty.plist.Item(1).X - Me.OperShapeProperty.plist.Item(0).X
            Ylength = Me.OperShapeProperty.plist.Item(1).Y - Me.OperShapeProperty.plist.Item(0).Y

            dp4.X = dp3.X - Xlength
            dp4.Y = dp3.Y - Ylength



            '下面进入精彩绝伦，绕死你不偿命的正反线绘制阶段

            ControlPaint.DrawReversibleLine(getScreen(Me.OperShapeProperty.plist.Item(1)), getScreen(dp3_old), lColor)

            ControlPaint.DrawReversibleLine(getScreen(Me.OperShapeProperty.plist.Item(1)), getScreen(dp3), lColor)


            ControlPaint.DrawReversibleLine(getScreen(Me.OperShapeProperty.plist.Item(0)), getScreen(dp4_old), lColor)

            ControlPaint.DrawReversibleLine(getScreen(Me.OperShapeProperty.plist.Item(0)), getScreen(dp4), lColor)


            ControlPaint.DrawReversibleLine(getScreen(dp3_old), getScreen(dp4_old), lColor)

            ControlPaint.DrawReversibleLine(getScreen(dp3), getScreen(dp4), lColor)





            '刷新旧有坐标啦

            dp3_old = dp3
            dp4_old = dp4






        End If
    End Sub

    Public Overrides Sub mouseUp(ByVal sender As Object, ByVal e As AxMapWinGIS._DMapEvents_MouseUpEvent)

    End Sub

    Public Overrides Sub setself()

    End Sub

    Public Overrides Sub unSet()

    End Sub
End Class
